<template>
  <div class="hello">
    <div>{{$store.getters.userinfo.name||'未登录'}}</div>
    <div>{{$store.getters.islogin}}</div>

    <el-button @click="login()">login</el-button>
    <el-button @click="logout()">logout</el-button>
    <el-button @click="test()">test</el-button>

  </div>
</template>

<script>
import http from "../http";

export default {
  name: "HelloWorld",
  data: function() {
    return {
      msg: "Welcome to Your Vue.js App"
    };
  },
  methods: {
    login: function() {
      http
        .login("admin", "123456")
        .then(res => {
          console.log(res);
        })
        .catch(err => {
          console.log(err);
        });
    },
    logout: function() {
      this.$store.commit("logout");
    },
    test: function() {
      http
        .cache("/api/common/area.json")
        .then(res => {
          console.log(res);
        })
        .catch(err => {
          console.log(err);
        });
    }
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1,
h2 {
  font-weight: normal;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
